package com.ruoyi.obtain.service.impl;

import java.util.List;

import com.ruoyi.common.exception.GlobalException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.obtain.mapper.TValuationOnHelpMapper;
import com.ruoyi.obtain.domain.TValuationOnHelp;
import com.ruoyi.obtain.service.ITValuationOnHelpService;

/**
 * 帮扶评价Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-11-11
 */
@Service
public class TValuationOnHelpServiceImpl implements ITValuationOnHelpService 
{
    @Autowired
    private TValuationOnHelpMapper tValuationOnHelpMapper;

    /**
     * 查询帮扶评价
     * 
     * @param id 帮扶评价主键
     * @return 帮扶评价
     */
    @Override
    public TValuationOnHelp selectTValuationOnHelpById(Long id)
    {
        return tValuationOnHelpMapper.selectTValuationOnHelpById(id);
    }

    /**
     * 查询帮扶评价列表
     * 
     * @param tValuationOnHelp 帮扶评价
     * @return 帮扶评价
     */
    @Override
    public List<TValuationOnHelp> selectTValuationOnHelpList(TValuationOnHelp tValuationOnHelp)
    {
        return tValuationOnHelpMapper.selectTValuationOnHelpList(tValuationOnHelp);
    }

    /**
     * 新增帮扶评价
     * 
     * @param tValuationOnHelp 帮扶评价
     * @return 结果
     */
    @Override
    public int insertTValuationOnHelp(TValuationOnHelp tValuationOnHelp)
    {
        TValuationOnHelp tValuationOnHelp1 = selectTValuationOnHelpById(tValuationOnHelp.getId());
        if(tValuationOnHelp1!=null){
            throw new GlobalException("该帮扶已经评价过，请勿重复评价");
        }
        return tValuationOnHelpMapper.insertTValuationOnHelp(tValuationOnHelp);
    }

    /**
     * 修改帮扶评价
     * 
     * @param tValuationOnHelp 帮扶评价
     * @return 结果
     */
    @Override
    public int updateTValuationOnHelp(TValuationOnHelp tValuationOnHelp)
    {
        return tValuationOnHelpMapper.updateTValuationOnHelp(tValuationOnHelp);
    }

    /**
     * 批量删除帮扶评价
     * 
     * @param ids 需要删除的帮扶评价主键
     * @return 结果
     */
    @Override
    public int deleteTValuationOnHelpByIds(Long[] ids)
    {
        return tValuationOnHelpMapper.deleteTValuationOnHelpByIds(ids);
    }

    /**
     * 删除帮扶评价信息
     * 
     * @param id 帮扶评价主键
     * @return 结果
     */
    @Override
    public int deleteTValuationOnHelpById(Long id)
    {
        return tValuationOnHelpMapper.deleteTValuationOnHelpById(id);
    }
}
